package xjtu.se.articlecommunity.buser.queuemanage;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xjtu.se.articlecommunity.buser.queuemanage.dto.InsFeedDto1;
import xjtu.se.articlecommunity.buser.queuemanage.dto.InsFeedDto2;
import xjtu.se.articlecommunity.buser.queuemanage.dto.OrderDto;
import xjtu.se.articlecommunity.buser.queuemanage.impl.QueueManageService;
import xjtu.se.articlecommunity.common.Result;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/buser/queuemanage")
public class QueueManageAPI {
    @Resource
    QueueManageService queueManageService;

    @PostMapping("/uporder")
    public Result Uporder(@RequestBody OrderDto dto){
        queueManageService.UpOrder(dto);
        return Result.success();
    }
    @PostMapping("/downorder")
    public Result Downorder(@RequestBody OrderDto dto){
        queueManageService.DownOrder(dto);
        return Result.success();
    }
    @PostMapping("/delfeed")
    public Result DeleteFeed(@RequestBody OrderDto dto){
        queueManageService.RemoveFeed(dto);
        return Result.success();
    }

    @PostMapping("/insert1")
    public Result InsertFeed1(@RequestBody InsFeedDto1 dto){
        log.info(dto.toString());
        try {
            queueManageService.AddFeed1(dto);
            return Result.success();
        }catch (Exception e){
            return Result.fail(500,e.getMessage());
        }
    }
    @PostMapping("/insert2")
    public Result InsertFeed2(@RequestBody InsFeedDto2 dto){
        log.info(dto.toString());

        return Result.success();
    }
}
